package org.richin.lang.util;

import java.util.ArrayList;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class RegexUtil {
	/**
	 * Return the specified match "groups" from the pattern.
	 * For each group matched a String will be entered in the ArrayList.
	 * 
	 * @param pattern The Pattern to use.
	 * @param match The String to match against.
	 * @param group The group number to return in case of a match.
	 * @return
	 */
	public static ArrayList<String> getMatches(Pattern pattern, String match, int group) {
		ArrayList<String> matches = new ArrayList<String>();
		Matcher matcher = pattern.matcher(match);
		while (matcher.find()) {
			matches.add(matcher.group(group));
		}
		return matches;
	}

}
